﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Rob Ashton 2009
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@mvcex.com
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Moq;
using MvcEx.Configuration;

namespace MvcEx.Tests
{
    [TestFixture]
    public class MvcExApplicationViewEngineConfigurationSelectorTests
    {
        [Test]
        public void use_application_to_create_configuration()
        {
            var testConfiguration = new MvcExConfiguration();
            testConfiguration.Modules = new MvcExConfigurationModule[]{
                new MvcExConfigurationModule()
                { 
                    Name = "TestOne"
                },
                new MvcExConfigurationModule()
                {
                    Name = "TestTwo"
                }
            };

            var applicationMock = new Mock<IMvcExApplication>();
            applicationMock.Setup(x => x.GetActiveConfiguration()).Returns(testConfiguration);

            MvcExApplicationViewEngineConfigurationSelector provider = new MvcExApplicationViewEngineConfigurationSelector(
                applicationMock.Object);

            var viewEngineConfiguration = provider.GetConfiguration();

            Assert.NotNull(viewEngineConfiguration.Components);
            Assert.AreEqual(2, viewEngineConfiguration.Components.Length);
            Assert.AreEqual("TestOne", viewEngineConfiguration.Components[0]);
            Assert.AreEqual("TestTwo", viewEngineConfiguration.Components[1]);
        }
    }
}
